package cn.doitedu;

import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
import org.roaringbitmap.RoaringBitmap;

public class Bitmap32AddDateUDF extends UDF {

    public byte[] evaluate(BytesWritable bmBytes, int diff) {

        RoaringBitmap bitmap;

        if (bmBytes == null || bmBytes.getBytes() == null) {
            bitmap = RoaringBitmap.bitmapOf();
        } else {
            // 反序列化出bitmap对象
            bitmap = Bitmap32SerDeUtil.deSerBitmap(bmBytes.getBytes());
        }

        bitmap.add(diff);

        return Bitmap32SerDeUtil.serBitmap(bitmap);

    }

}
